﻿#include"definition.h"
	
int main() {
	graph g;
	IMAGE img_start[12];
	char nick_name[50]=" ";

	ifstream inputfile("route.txt");
	playmusic("op.mp3", true, 100);
	
	background(img_start,nick_name);
	mciSendString("close op.mp3", NULL, NULL, NULL);//关闭音乐
	//播放配乐
	playmusic("gamebgm2.mp3", true, 20);
	putimage(0, 0, img_start + 2);


	//利用文件信息创建图
	string site; 
	string name;
	while (inputfile >> site) {
		if (site == "train")
		{
			int start; int end;
			int mone; int len;
			inputfile >> start; inputfile >> end; inputfile >> mone; inputfile >> len;
			g.edgesmon[start][end] = mone;
			g.edgeslin[start][end] = len/vtrain+ttrain;
			bnode *a=new bnode(mone,len,end,ttrain,vtrain);
			if (g.list[start].firstb == NULL)g.list[start].firstb = a;
			else {
				bnode* b = g.list[start].firstb;
				while (b->nextb != NULL) {
					b = b->nextb;
				}
				b->nextb=a;
			}
		}
		else if (site == "plane")
		{
			int start; int end;
			int mone; int len;
			inputfile >> start; inputfile >> end; inputfile >> mone; inputfile >> len;
			g.edgesmon[start][end] = mone;
			g.edgeslin[start][end] = len/vplane+tplane;
			bnode* a = new bnode(mone, len, end, tplane, vplane);
			if (g.list[start].firstb == NULL)g.list[start].firstb = a;
			else {
				bnode* b = g.list[start].firstb;
				while (b->nextb != NULL) {
					b = b->nextb;
				}
				b->nextb=a;
			}
		}
		else 
		{
			int number = char(site[0]) - '0';
			inputfile >> name;
			g.city[number] = name;
			g.n = g.n + 1;
			g.list[number] = hnode(name,number);
		}
	}
	
	getchoice(img_start,nick_name,g);
	inputfile.close(); // 关闭文件
	return 0;
}
